#ifndef TD_RESOURCE_MANAGER
#define TD_RESOURCE_MANAGER


/************************************************************************/
/* STL                                                                     */
/************************************************************************/
#include <string>

/************************************************************************/
/* BOOST                                                                */
/************************************************************************/
#include "boost/smart_ptr/shared_ptr.hpp"
#include "boost/smart_ptr/weak_ptr.hpp"

/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/
#include "Core/Singleton.h"
#include "Core/Manager.h"

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/Tiles/Tileset.h"
#include "Resources/SFX/SDLMusic.h"
#include "Resources/SFX/SDLSound.h"
#include "Resources/SDLFont.h"
#include "Resources/Resource.h"
#include "Resources/XMLDoc.h"

//Game definitions
#include "GAme/GameCore.h"


using namespace std;
using namespace boost;
using namespace TD_Core;

namespace TD_Resources {

	class ResourceManager : public Singleton<ResourceManager> {

	protected:

		//Accessing the objects through strings
		static map<string, weak_ptr<Resource> > m_objStringMap;

	public:

		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit ResourceManager();

		//Copy constructor
		explicit ResourceManager(const ResourceManager &rhs);

		//Assignment constructor
		ResourceManager& operator=(const ResourceManager &rhs);

		//Destructor
		~ResourceManager();

		/************************************************************************/
		/* Access functions                                                     */
		/************************************************************************/

		inline weak_ptr<Resource> getObject(const string &objName) {
			map<string, weak_ptr<Resource> >::const_iterator iter = m_objStringMap.find(objName);
			if(iter == m_objStringMap.end()) 
				return weak_ptr<Resource>();
			return(iter->second);
		}


		inline void createObject(const string &objName, weak_ptr<Resource> pResource) {

			m_objStringMap[objName] = pResource;
		}
			
		/************************************************************************/
		/* Functionalities                                                      */	
		/************************************************************************/

		static shared_ptr<Tileset> loadCharacterTileset(string resourcePath, Coord2D tileSize, const Color &keyColor = Color::BLACK);
		static shared_ptr<Tileset> loadTileset(const string &resourcePath, Coord2D tileSize, const Color &keyColor = Color::BLACK);

		static shared_ptr<SDLFont> loadFont(const string &fontPath, unsigned int fontSize);

		static shared_ptr<SDLImage> loadImage(const string &imagePath);
		static shared_ptr<SDLImage> loadImage(const string &imagePath, const Color &keyColor);

		static shared_ptr<SDLMusic> loadMusic(const string &musicPath);
		static shared_ptr<SDLSound> loadSound(const string &soundPath);
      static shared_ptr<XMLDoc> loadXMLDocument(const string &xmlPath);
	};
}




#endif